//
//  BLEConfigurationManager.h
//  BLE_Configuration_SDK
//
//  Created by Ron on 2023/3/2.
//

#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import <BLE_Configuration_SDK/BluetoothCodeType.h>
#import <BLE_Configuration_SDK/Log.h>

NS_ASSUME_NONNULL_BEGIN

typedef void (^ResultBlock)(BluetoothCodeType code);

typedef void (^SetupBlock)(BOOL isSuccessful);

typedef void (^LogBlock)(Log *log);

/**
 * 蓝牙状态改变
 */
extern NSString *const BLEBluetoothStateDidChange;

@interface BLEConfigurationManager : NSObject

@property(nonatomic, assign, readonly) CBManagerState bluetoothState;
/**
 * 是否初始化成功
 */
@property (nonatomic, assign, readonly) BOOL isSetupFinished;

@property (nonatomic, readonly) NSString *version;

+ (instancetype)shared;

/**
 * Check id and token of SDK
 * - Parameter appKey : app key of SDK
 * - Parameter result: result
 */
- (void)setupWithAppKey:(NSString *)appKey result:(SetupBlock)result;

/**
 * 初始化AP 配网
 * - Parameter sn : 采集器SN
 * - Parameter ssid : 路由器SSID
 * - Parameter password: 路由器Password
 * - Parameter result: 配网结果
 */
- (void)startConfigurationManagerWithSn:(NSString *)SN ssid:(NSString *)SSID password:(NSString * _Nullable)Password log:(LogBlock)log result:(ResultBlock)result;
/**
 * 退出配网
 */
- (void)exitConfigurationManager;

/**
 * Get logs of last configuration
 */
- (NSArray *)getLogsOfLastConfiguration;


@end

NS_ASSUME_NONNULL_END
